import 'package:fish_redux/fish_redux.dart';
import 'action.dart';
import 'state.dart';
import 'package:kunlun_gas/app_files.dart';

Effect<HotLineViewState> buildEffect() {
  return combineEffects(<Object, Effect<HotLineViewState>>{
    Lifecycle.initState: _initState,
  });
}

void _initState(Action action, Context<HotLineViewState> ctx) async {
  ResultData res = await CommonNetWork.getSystemConfig();
  if (res.success) {
    List data = res.data;
    Map config = data.first;
    List value = config['ConfigValue'];
    value.forEach((element) {
      if (element['Key'] == 'company') {
        ctx.state.companyName = element['Value'];
      }
      if (element['Key'] == 'mobile') {
        ctx.state.consumerPhone = element['Value'];
      }
    });
  }
  ctx.dispatch(HotLineViewActionCreator.onAction());
}
